package gluck.util;

import java.io.File;
import java.io.FilenameFilter;

public class FileUtil {

  String filter;
  
  public String[] listFiles(String dir, final String filter) {

    File directory = new File(dir);
    this.filter = filter;

    if (!directory.isDirectory()) {
      System.out.println("No directory provided");
      return null;
    }

    //create a FilenameFilter and override its accept-method
    FilenameFilter filefilter = new FilenameFilter() {

      public boolean accept(File dir, String name) {
        return name.endsWith(filter);
      }
    };

    String[] filenames = directory.list(filefilter);

    return filenames;

  }
  

}